package com.ebupt.migu.music.global.controller;

import com.ebupt.migu.music.common.entity.ResultObject;
import com.ebupt.migu.music.global.service.GlobalFileService;
import com.ebupt.migu.music.global.service.impl.GlobalFileServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


import java.util.Map;

/**
 * @Author liuyangyang@ebupt.com
 * @update wangzhu
 * @Description
 * @Date 2021/11/23 10:04
 */
@Slf4j
@RestController
@RequestMapping("/global/action")
public class GlobalFileController {

    @Autowired
    private GlobalFileServiceImpl globalFileService;

    /**
     * 弹窗类型查询
     */
    @GetMapping("/list")
    public ResultObject getlist() {
        return globalFileService.getlist();
    }


    /**
     * 活动名称校验
     */
    @GetMapping("/isName")
    public ResultObject isName(@RequestParam String name,@RequestParam String activityId) {
        return globalFileService.isName(name,activityId);
    }

    /**
     * 文件上传
     */
    @PostMapping("/uploadFile")
    public ResultObject uploadFile(MultipartFile file, Integer type) {
        return globalFileService.uploadFile(file, type);
    }


    /**
     * 删除文件
     */
    @PostMapping("/delFile")
    public ResultObject delFile(@RequestParam String fileName,@RequestParam Integer type) {
        return globalFileService.delFile(fileName, type);
    }


}
